#include "api/api.h"
#include "env/env.h"
// #include "init/init.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char *argv[], char *const envp[]) {
    printf("Start running...\n");
    char *img_path = parse_env(envp, "IMG_FILE");
    if (img_path == NULL) {
        fprintf(stderr, "[neodocker]: environment variable IMG_FILE not set\n");
        return EXIT_FAILURE;
    }
    // char *_argv[3] = {"top", "-b", NULL};
    // assert(setregid(1000, 1000) == 0);
    // assert(setreuid(1000, 1000) == 0);
    int container_id = create(img_path, "top -b");
    assert(container_id != 0);
    // int container_id = cntr_create(img_path, "top", _argv);
    // assert(cntr_attach(2124148342, "bash", argv) == 0);
    assert(update(container_id, 'c', 10) == 0);
    assert(update(container_id, 'm', 50) == 0);
    assert(update(container_id, 'n', 8) == 0);
    assert(attach(container_id, "bash") >= 0);
    /// wait for 10s

    // assert(cntr_delete(container_id) == 0);
    assert(delete (container_id) == 0);
    printf("Quit running...\n");
    return EXIT_SUCCESS;
}
